package poker;

import java.util.Scanner;

public final class Poker 
{
	private Poker() {}
	public static void main(final String[] args) 
	{
		System.out.println("Poker game");
		System.out.println("How many players? (2-4)");
		Scanner sc = new Scanner(System.in);
		String input = "y";
		int players = sc.nextInt();
		Table table;
		System.out.println("How many human players?");
		int human = sc.nextInt();
		int i = 0;
		String[] humanNames = new String[4];
		while((i < human) && (i < 4))
		{
			System.out.println("Player " + (i + 1) + " name: ");
			humanNames[i] = sc.next();
			i++;
		}
				
		System.out.println("How many chips per player?");
		int chips = sc.nextInt();
		System.out.println("How many chips to buy-in?");
		int buyIn = sc.nextInt();
		while (!input.equals("n")) 
		{
			try 
			{
				table = new Table(players, human, humanNames, chips, buyIn);
			} 
			catch (PokerException e) 
			{
				System.out.println(e.getMessage());
				e.printStackTrace();
				sc.close();
				return;
			}
		
			table.play();
			System.out.println("Play again? (y/n)");
			input = sc.next();
		}
		sc.close();
	}
}